﻿#define CATCH_CONFIG_MAIN
#include "catch.hpp"
#include "filter/medianFilter1D.h"

using std::vector;
using Catch::Matchers::WithinAbs;

TEST_CASE("medianFilter1D", "[medianFilter1D]")
{
    vector<double> signal = {1, 2, 3, 100, 5, 6, 7}; // 含噪声
    auto filtered = medianFilter1D(signal, 3);

    CHECK_THAT(filtered[0], WithinAbs(2, 0.1));
    CHECK_THAT(filtered[1], WithinAbs(2, 0.1));
    CHECK_THAT(filtered[2], WithinAbs(3, 0.1));
    CHECK_THAT(filtered[3], WithinAbs(5, 0.1));
    CHECK_THAT(filtered[4], WithinAbs(6, 0.1));
    CHECK_THAT(filtered[5], WithinAbs(6, 0.1));
    CHECK_THAT(filtered[6], WithinAbs(7, 0.1));
}
